]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/Tests/Unit Tests/DNSMessageTest.m
mDNSResponder-1096.40.7.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / Tests / Unit Tests / DNSMessageTest.m
1 /*
2 * Copyright (c) 2017-2018 Apple Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "mDNSEmbeddedAPI.h"
18 #include "DNSCommon.h"
19 #import <XCTest/XCTest.h>
20
21 @interface DNSMessageTest : XCTestCase
22 {
23 DNSMessage *msg;
24 }
25 @end
26
27 @implementation DNSMessageTest
28
29 - (void)setUp
30 {
31 msg = (DNSMessage *)malloc (sizeof(DNSMessage));
32 XCTAssert(msg != NULL);
33
34 // message header should be 12 bytes
35 XCTAssertEqual(sizeof(msg->h), 12);
36 }
37
38 - (void)tearDown
39 {
40 XCTAssert(msg != NULL);
41 free(msg);
42 }
43
44 - (void)testMessageInitialization
45 {
46 // Initialize the message
47 InitializeDNSMessage(&msg->h, onesID, QueryFlags);
48
49 // Check that the message is initialized properly
50 XCTAssertEqual(msg->h.numAdditionals, 0);
51 XCTAssertEqual(msg->h.numAnswers, 0);
52 XCTAssertEqual(msg->h.numQuestions, 0);
53 XCTAssertEqual(msg->h.numAuthorities, 0);
54 }
55
56 #if 0
57 - (void)testPerformanceExample {
58 // This is an example of a performance test case.
59 [self measureBlock:^{
60 // Put the code you want to measure the time of here.
61 }];
62 }
63 #endif
64
65 @end